{include file="public/layout" /}
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 
<span class="c-gray en">&gt;</span> 权限管理
<span class="c-gray en">&gt;</span> 添加角色
<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i>
</a>
</nav>
<article class="page-container" style="margin-top: 50px;">
	<form action="{:U('Admin/role/roleSave')}" method="post" class="form form-horizontal" id="form-admin-role-add">
		<input type="hidden" name="role_id" value="{$detail.role_id ? $detail.role_id : ''}">
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3"><span class="c-red">*</span>角色名称：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" name="roleName" id="roleName" value="{$detail.role_name ? $detail.role_name : ''}" style="width: 60%;">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">备注：</label>
			<div class="formControls col-xs-8 col-sm-9">
				<input type="text" class="input-text" id="role_desc" name="data[role_desc]" value="{$detail.role_desc ? $detail.role_desc : ''}" style="width: 60%;">
			</div>
		</div>
		<div class="row cl">
			<label class="form-label col-xs-4 col-sm-3">权限分配：</label>
			<div class="formControls col-xs-8 col-sm-9">
			{if isset($modules)}
			{foreach name="modules" item="menu" key="kk" }
				<dl class="permission-list">
					<dt>
						<label>
							<input type="checkbox" value="" name="user-Character-0" id="user-Character-0">{if isset($group[$kk])}{$group[$kk]}{/if}
						</label>
					</dt>
					<dd>
						<dl class="cl permission-list2">
							<dd>
								{if isset($menu)}
									{foreach name="menu" item="vv" }
									<label><input class="checkbox" name="right[]" value="{$vv.id}" {if isset($vv.enable)}{if $vv.enable==1} checked {/if} {/if} ck="mod-{$kk}" type="checkbox">{if isset($vv.name)}{$vv.name}{/if}</label>
									{/foreach}
								{/if}
							</dd>
						</dl>
					</dd>
				</dl>
			{/foreach}
			{/if}
			</div>
		</div>
		<div class="row cl">
			<div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
				<button type="submit" class="btn btn-primary radius" id="admin-role-save" name="admin-role-save"><i class="icon-ok"></i> 确定</button>
				<button type="button" class="btn btn-success radius" id="admin-role-save" name="admin-role-save" onclick="javascript:history.go(-1);"><i class="icon-ok"></i> 返回上一页</button>
			</div>
		</div>
	</form>
</article>
{include file="public/footer" /}
<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/public/h-ui.admin/lib/jquery.validation/1.14.0/jquery.validate.js"></script>
<script type="text/javascript" src="/public/h-ui.admin/lib/jquery.validation/1.14.0/validate-methods.js"></script>
<script type="text/javascript" src="/public/h-ui.admin/lib/jquery.validation/1.14.0/messages_zh.js"></script>
<script type="text/javascript">
$(function(){
	$(".permission-list dt input:checkbox").click(function(){
		$(this).closest("dl").find("dd input:checkbox").prop("checked",$(this).prop("checked"));
	});
	$(".permission-list2 dd input:checkbox").click(function(){
		var l =$(this).parent().parent().find("input:checked").length;
		var l2=$(this).parents(".permission-list").find(".permission-list2 dd").find("input:checked").length;
		if($(this).prop("checked")){
			$(this).closest("dl").find("dt input:checkbox").prop("checked",true);
			$(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",true);
		}
		else{
			if(l==0){
				$(this).closest("dl").find("dt input:checkbox").prop("checked",false);
			}
			if(l2==0){
				$(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked",false);
			}
		}
	});
	
	$("#form-admin-role-add").validate({
		rules:{
			roleName:{
				required:true,
			},
		},
		onkeyup:false,
		focusCleanup:true,
		success:"valid",
	});
});
</script>
<!--/请在上方写此页面业务相关的脚本-->
</body>
</html>